// 控件管理接口
import { ajaxService } from '@/utils/request';
import * as ctl from './type';

const env = import.meta.env;
const baseURL = env.VITE_BASE_URL;
/**
 *
 * @param data 添加控件
 * @returns
 */
export async function AddControl(data: ctl.Control) {
  return ajaxService({
    url: '/platform_ccc/control/ctl',
    method: 'post',
    baseURL,
    data
  });
}
/**
 * 获取控件列表
 * @param params
 * @returns
 */
export async function getControlList(params: ctl.ControlParams) {
  return ajaxService<{ content: any }>({
    url: '/platform_ccc/control/ctl/list',
    method: 'get',
    baseURL,
    params
  });
}
/**
 * 获取所有控件
 * @returns
 */
export async function getControlAll() {
  return ajaxService<any>({
    url: '/platform_ccc/control/all/ctl/list',
    method: 'get',
    baseURL
  });
}
export async function getControlById(id: number) {
  return ajaxService<{ content: any }>({
    url: `/platform_ccc/control/ctl/${id}`,
    method: 'get',
    baseURL
  });
}
/**
 * 编辑控件
 * @param params
 * @returns
 */
export async function editControl(data: ctl.Control) {
  return ajaxService({
    url: '/platform_ccc/control/ctl',
    method: 'put',
    baseURL,
    data
  });
}
/**
 * 删除控件
 * @param params
 * @returns
 */
export async function delControlByIds(data: { ids: number[] }) {
  return ajaxService({
    url: `/platform_ccc/control/ctl`,
    method: 'delete',
    baseURL,
    data
  });
}
